/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2024-09-11
 * Time: 15:27
 */
public class Test {
    public static void main(String [] args ){
       /* int max = cmp(6,9,8);
        int max2 = cmp(9,6);
        System.out.println(max);
        System.out.println(max2);*/
       // int ass = func1(5);
        //int ass2 = func2(1239);
       // int fi = fib(40);
       // System.out.println(ass);
        //System.out.println(fi);

        int fin = fiBn(1);
        System.out.println(fin);




    }
    public static int fiBn(int n){ //循环的方法递归
        int f1 = 1;
        int f2 = 1;
        int f3 = 0;
        if (n==1||n==2){
            return 1;
        }
        for (int i=3;i <= n;i++){
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }
    public static int fib(int n){  //递归
        if(n==1||n == 2){
            return 1;
        }
        return fib(n-1)+fib(n-2);
    }
    public static int func2(int n){
        if (n<10){
            return n;
        }

        return  n % 10 + func2(n/10);

    }
    public static int func1(int n){
        if(n==1){
            return 1;
        }
        return  (n + func1(n-1));

    }
    public static int cmp(int a,int b){ //比较两个 三个数最大数
        return Math.max(a,b);
    }
    public static int cmp (int a,int b,int c) {
        int tmp = Math.max(a,b);
        return Math.max(tmp,c);
    }
}

